{% from "macros/forms.html" import form_input %}
{% set publisher_id = publisher_preset.id | default("0", true) %}
{% set publisher_type = publisher_preset.type | upper %}

<div class="bg-base-100 p-4">
  <h1 class="text-3xl font-bold mb-5 w-3/4 ml-[10%]">{{ submit_text }}</h1>
  <p class="text-base-content/60 text-[0.7rem] mb-5 w-1/2 ml-[10%]">ID: {{ publisher_id }}</p>
  <form id="publisher_preset-form"
        class="w-3/4 ml-[10%]"
        {{ form_action }}
        hx-swap="innerHTML"
        hx-target="#form-container"
        hx-target-error="#form-container">
    {% include "partials/admin_form_error.html" %}
    {{ form_input('Name', 'name', publisher_preset.name, form_error.name, width="w-3/4") }}
    {{ form_input('Description', 'description', publisher_preset.description, form_error.description, required=false, width="w-3/4") }}
    <label class="select w-3/4 mb-5">
      <span class="label">Publisher Type</span>
      <select id="publisher_type"
              name="type"
              required
              class="validator select w-full {% if publisher_preset.type %}pointer-events-none opacity-60{% endif %}"
              hx-get="{{ url_for('admin.publisher_parameters', publisher_id=publisher_id) }}"
              hx-trigger="change"
              hx-include="#publisher_type"
              hx-target="#parameters"
              hx-swap="innerHTML">
        {% if not publisher_preset.type %}<option value="" selected disabled>Select a publisher type</option>{% endif %}
        {% for option in publisher_types %}
          <option value="{{ option.id }}" {% if option.id == publisher_type %}selected{% endif %}>{{ option.name }}</option>
        {% endfor %}
      </select>
    </label>
    <div id="parameters">{% include "partials/worker_parameters.html" %}</div>

    <input type="submit" class="btn btn-primary w-3/4" value="{{ submit_text }}" />
  </form>
</div>
